﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class LogicalBoard
{
    /// <summary>
    /// The grid of signals on each grid.
    /// </summary>
    private string[] signals;

    /// <summary>
    /// The game city object managed by this board.
    /// </summary>
    public City city = null;

    public int width = 12;
    public int height = 8;

    #region Constructors

    public LogicalBoard(int width, int height)
    {
        this.width = width;
        this.height = height;

        signals = new string[width * height];

        city = new City(width, height);
    }

    #endregion

    #region Public Methods

    /// <summary>
    /// Use this method to update signal data on the board.
    /// </summary>
    /// <param name="x"></param>
    /// <param name="y"></param>
    /// <param name="signal"></param>
    public void UpdateSignal(int x, int y, string signal)
    {
        int index = y * width + x;
        if (signals[index] != signal)
        {
            // Changed!
            signals[index] = signal;

            if (string.IsNullOrEmpty(signal))
            {
                // TODO: Remove the Building at x, y in the City.
            }
            else
            {
                // TODO: Map the signal to a building template.
                // Construct the building template.
                // Add the building to the City at the appropriate location.
                //
                // For buildings larger than one space, put in a pause cycle
                // to wait for the next signal. All we need is a second signal
                // in order to determine orientation and location, assuming
                // that each signal for the building is unique.
            }
        }

    }

    #endregion


}
